import pandas as pd

class DataLoader:
    def __init__(self, csv: str or pd.DataFrame, x_label: list, y_label: list) -> None:
        if type(csv) == str:
            csv = pd.read_csv(csv)
        elif type(csv) == pd.DataFrame:
            pass
        self.xs = csv[x_label].values
        self.ys = csv[y_label].values

    def __len__(self):
        return len(self.xs)
    
    def __getitem__(self, idx):
        return self.xs[idx], self.ys[idx]

if __name__ == '__main__':
    data = DataLoader(pd.read_csv('./3.0a.csv'), ['密度', '含糖率'], ['好瓜'])
    for x, label in data:
        print(x, label)